<?php
include_once("dbconnect.php");


if(isset($_POST["submit"])){
    $email = $_POST["email"];
    $password = $_POST["password"];
    
    $sql = "SELECT email, password FROM user WHERE email = '$email' AND password = '$password'";
    $result = $connection->query($sql);
    $row = $result->fetch_assoc();
    
    if ($email == $row['email'] && $password == $row['password']) {
        $_SESSION['email'] = $row['email'];
        $_SESSION['password'] = $row['password'];
        header('Location : 1_homepage.php');
        
    } else {
        echo "<script>alert('Invalid Email or Password');</script>";
        echo "<script>window.location.href='login.php';</script>";
        exit();
    }
    
    }
?>